package com.woniu.airent.service.impl;

import com.woniu.airent.dto.HouseDto;
import com.woniu.airent.dto.ImgsDto;
import com.woniu.airent.mapper.ExtraMapper;
import com.woniu.airent.mapper.HouseImgMapper;
import com.woniu.airent.mapper.HouseMapper;
import com.woniu.airent.mapper.ItemsMapper;
import com.woniu.airent.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class HouseServiceImpl implements HouseService {
    @Autowired
    HouseMapper houseMapper;

    @Autowired
    HouseImgMapper houseImgMapper;

    @Autowired
    ExtraMapper extraMapper;

    @Autowired
    ItemsMapper itemsMapper;

    @Override
    @Transactional
    public int addHouse(HouseDto house) {

        int insert = houseMapper.MyInsert(house);
        System.out.println(house.getHouseId());
        //插入图片
        List<ImgsDto> imgs = house.getImgs();
        for (ImgsDto img :
                imgs) {
            int result = houseImgMapper.Myinsert(house.getHouseId(),img.getImgAdress());
        }
        //插入水电燃气
        

        //插入房屋设施


        return insert;

    }



}
